<template>
  <el-dialog title="修改有效期" :model-value="visible" width="700px" :fullscreen="mobile" @close="handleCancel">
    <el-form :model="delayForm" label-width="100px">
      <el-form-item label="姓名：" prop="username">{{ delayForm.username }}</el-form-item>
      <el-form-item label="密码：" prop="keyboardPwd">
        <el-input v-model="delayForm.keyboardPwd" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item label="有效期：" required>
        <el-row>
          <el-col :span="11">
            <el-form-item prop="startDate">
              <el-date-picker
                v-model="delayForm.startDate"
                type="datetime"
                format="YYYY-MM-DD HH:mm"
                placeholder="请选择开始时间"
              />
            </el-form-item>
          </el-col>
          <el-col :span="2" align="center">-</el-col>
          <el-col :span="11">
            <el-form-item prop="endDate">
              <el-date-picker
                v-model="delayForm.endDate"
                type="datetime"
                format="YYYY-MM-DD HH:mm"
                placeholder="请选择结束时间"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button type="primary" @click="handleOk">确定</el-button>
    </template>
  </el-dialog>
</template>
<script setup name="delayDl">
import useAppStore from '@/store/modules/app'

const emit = defineEmits()
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  form: {
    type: Object,
    default: () => {}
  }
})

const delayForm = ref({})

watch(() => props.visible, (value) => {
  if (value) {
    delayForm.value = { ...props.form }
  }
})

const mobile = computed(() => useAppStore().device === 'mobile')

function handleOk() {
  emit('ok', delayForm.value)
}
function handleCancel() {
  emit('cancel')
}
</script>
